from collections import namedtuple

# 1 1 2 3 5 8,13,21,34,55

# 利用循环递归来实现斐波那契列数
"""
nums = [1, 2, 3, 4]
print(type(nums[0:2]), sum(nums[0:2]))


def fibonacci(n):
    list_sum = []

    for i in range(n):
        # i=[0,1]
        if i == 0 or i == 1:
            list_sum.append(1)
        else:
            # i=[0,1,2]

            result = sum(list_sum[i - 2 : i])
            list_sum.append(result)

    return list_sum


# num_3 = fibonacci(5)

# print("num_3=", num_3)
num = 100

num_3 = fibonacci(num)
print("num_3=", num_3)
"""

xx_nums_dict = {"0": 1}
print(xx_nums_dict["0"])


def get_fiboacc(n):
    nums_dict = {}

    for i in range(n):
        key = str(i)
        if key not in nums_dict:
            if i == 0 or i == 1:
                nums_dict[key] = 1
            else:
                prev_key = str(i - 1)
                prev_prev_key = str(i - 2)
                nums_dict[key] = nums_dict[prev_key] + nums_dict[prev_prev_key]

    return nums_dict


fibacc_list = get_fiboacc(10)
print("fibacc_list(1)=", fibacc_list.values())
